package com.cy.zs.hp.controller;

import com.cy.zs.hp.feign.service.IHisDoctorFeignService;
import com.cy.zs.hp.feign.service.IHisRegisterFeignService;
import com.cy.zs.hp.model.HisDoctor;
import com.cy.zs.hp.model.HisRegister;
import com.cy.zs.hp.model.SchedulingTable;
import com.cy.zs.web.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class PageController {

    @Autowired
    private IHisRegisterFeignService iHisRegisterFeignService;
    @Autowired
    private IHisDoctorFeignService iHisDoctorFeignService;
    @RequestMapping("/")
    public String findlogin() {
        return "pages/login";
    }

    @RequestMapping("/hp/hisUser/login")
    public String find() {
        return "pages/zhuce1";
    }

    @RequestMapping("/hp/hisUser/doregister")
    public String find1() {
        return "pages/login";
    }

    @RequestMapping("/hp/hisUser/zhuce1.html")
    public String find2() {
        return "pages/zhuce1";
    }

    @RequestMapping("/zhuce1.html")
    public String find6() {
        return "pages/zhuce1";
    }

    @RequestMapping("/hp/hisUser/main")
    public String find3() {
        return "pages/index";
    }

    @RequestMapping("/hp/hisUser/main-1/{doctorId}/{patientId}")
    public String find8(@PathVariable String doctorId, @PathVariable String patientId, Model model) {
        Integer id = Integer.valueOf(doctorId);
        JsonResult<List<SchedulingTable>> jsonResult = iHisDoctorFeignService.findSchedulingTableByDoctorId(id);//远程调用，查询医师工作表
        List<SchedulingTable> workTimeTable = jsonResult.getData();
        model.addAttribute("workTimeTable", workTimeTable);
        JsonResult<List<HisRegister>> listJsonResult = iHisRegisterFeignService.findByDoctorId(doctorId, patientId);//根据医生和患者id查询
        List<HisRegister> registersTable = listJsonResult.getData();
        model.addAttribute("registersTable", registersTable);
        return "pages/index-1";
    }

    @RequestMapping("/hp/hisUser/index2.html")
    public String find4() {
        return "pages/yuyueui";
    }

    /*查询科室*/
    @RequestMapping("/hp/hisUser/doFindDepartment")
    public String doFindDepartment(Model model) {
        JsonResult<List<HisDoctor>> jsonResult = iHisDoctorFeignService.findDepartment();//远程调用查询所有部门
        List<HisDoctor>  hisDoctors = jsonResult.getData();
        model.addAttribute("hisDoctors", hisDoctors);
        return "pages/yuyueui";
    }

    /**
     * 查找对应科室医生
     *
     * @param department
     * @param model
     * @return
     */
    @RequestMapping("/doFindByDepartment/{department}")
    public String doFindByDepartment(@PathVariable String department, Model model) {
        JsonResult<List<HisDoctor>> jsonResult = iHisDoctorFeignService.findByDepartment(department);//查询对应的部门医生
        List<HisDoctor>  hisDoctors = jsonResult.getData();
        model.addAttribute("hisDoctors", hisDoctors);
        return "pages/doctor";
    }

    /**
     * 填写患者信息
     *
     * @return
     */
    @RequestMapping("/patientInfo")
    public String patientInfo() {
        return "pages/patientInfo";
    }



}